<?php 
	$this->lang->load('template');
	$mediaType = array('text'=>'文本', 'image'=>'图片');
?>
<fieldset>
  <div class="yui-gc">
	 <form action="" method="post" enctype="multipart/form-data">
      <input type="hidden" name="redirect" value="<?=getUrl(false);?>" />
      <input type="hidden" name="id" value="<?=isset($adv['id']) ? $adv['id'] :''?>" />
      <div class="yui-u first">
        <p>
          <label for="ad_name">广告名称</label>
          <span class="required">*</span><br>
          <input class="title fullwidth" id="ad_name" name="ad_name" size="30" value="<?=isset($adv['ad_name'])?$adv['ad_name']:''?>" type="text">
        </p>
        <p id="ad_link" style="display:" class="form_item">
          <label for="ad_link">广告链接</label>
          <span class="required">*</span> <br />
          <input id="ad_link" name="ad_link" size="30" value="<?=isset($adv['ad_link'])?$adv['ad_link']:''?>" type="text">
        </p>
        <p id="ad_image" style="display:" class="form_item">
          <label for="ad_image">上传广告图片</label>
          <span class="required">*</span> <br />
          <input id="ad_image" name="ad_image" size="30" type="file" />
          <br>
        </p>
        <p id="ad_image_url" style="display:" class="form_item">
          <label for="ad_image_url">或者输入图片网址</label>
          <span class="required">*</span> <br />
          <input id="ad_image_url" name="ad_image_url" size="30" value="<?=isset($adv['ad_code'])?$adv['ad_code']:''?>" type="text">
        </p>
        <p id="ad_flash" style="display:none" class="form_item">
          <label for="ad_flash">上传FLASH文件</label>
          <span class="required">*</span> <br />
          <input id="ad_flash" name="ad_flash" size="30" type="file">
          <br>
        </p>
        <p id="ad_flash_url" style="display:none" class="form_item">
          <label for="ad_flash_url">或者输入FLASH网址</label>
          <span class="required">*</span> <br />
          <input id="ad_flash_url" name="ad_flash_url" size="30" value="<?=isset($adv['ad_code'])?$adv['ad_code']:''?>" type="text">
        </p>
        <p id="ad_text" style="display:none" class="form_item">
          <label for="ad_text">广告内容</label>
          <br>
          <textarea cols="40" id="ad_text" name="ad_text" style="width:auto; height:60px;"><?=isset($adv['ad_code'])?$adv['ad_code']:''?>
</textarea>
        </p>
        <p id="ad_code" style="display:none" class="form_item">
          <label for="ad_code">广告代码</label>
          <br>
          <textarea cols="40" id="ad_code" name="ad_code" style="width:auto; height:60px;"><?=isset($adv['ad_code'])?$adv['ad_code']:''?></textarea>
        </p>
      </div>
      <div class="yui-u">
        <p>
          <label for="media_type">媒介类型</label>
          <span class="required">*</span> <br />
          <select id="media_type" name="media_type" style="width:200px" onChange="loadMediaTypeFeild(this.options[this.selectedIndex].value)">
            <?php foreach($mediaType as $v=>$l): ?>
            <option value="<?=$v?>"<?php if(isset($adv['media_type']) && $v==$adv['media_type']): ?> selected="selected"<?php endif;?>>
            <?=$l?>
            </option>
            <?php endforeach;?>
          </select>
        </p>
        <p>
          <label for="start_at">开始时间</label>
          <br />
          <input class="format_date" id="start_at" name="start_at" size="30" type="text" value="<?=isset($adv['start_at'])?date("Y-m-d",$adv['start_at']):0?>" readonly="readonly" />
        </p>
        <p>
          <label for="end_at">结束时间</label>
          <br />
          <input class="format_date" id="end_at" name="end_at" size="30" type="text" value="<?=isset($adv['end_at'])?date("Y-m-d",$adv['end_at']):0?>" readonly="readonly" />
        </p>
      </div>
      <p class="form-buttons">
        <button type="submit"><span><?=$this->lang->line('tpl_submit')?></span></button>
        <a href="<?=getUrl(false)?>"><?=$this->lang->line('tpl_cancel')?></a> </p>
    </form>
  </div>
</fieldset>